import request from '@/utils/request';

// 获取街道列表
export const listStreet = async (params) => {
  try {
    const response = await request({
      url: '/htzj/streets/list',
      method: 'get',
      params
    });
    return response.data;
  } catch (error) {
    console.error('获取街道列表失败', error);
    throw error;
  }
};

// 获取街道分页列表
export const pageListStreet = async (params) => {
  try {
    const response = await request({
      url: '/htzj/streets/pageList',
      method: 'get',
      params
    });
    return response;
  } catch (error) {
    console.error('获取街道分页列表失败', error);
    throw error;
  }
};

// 删除街道
export const delStreet = async (streetId) => {
  try {
    const response = await request({
      url: `/htzj/streets/${streetId}`,
      method: 'delete'
    });
    return response.data;
  } catch (error) {
    console.error('删除街道失败', error);
    throw error;
  }
};

// 添加街道
export const addStreet = async (data) => {
  try {
    const response = await request({
      url: '/htzj/streets',
      method: 'post',
      data
    });
    return response.data;
  } catch (error) {
    console.error('添加街道失败', error);
    throw error;
  }
};

// 更新街道
export const updateStreet = async (data) => {
  try {
    const response = await request({
      url: '/htzj/streets',
      method: 'put',
      data
    });
    return response.data;
  } catch (error) {
    console.error('更新街道失败', error);
    throw error;
  }
};
